var e = getApp(), t = e.requirejs("core"), i = e.requirejs("foxui"), a = e.requirejs("jquery");

Page({
  data: {
    member: {},
    binded: !1,
    endtime: 0,
    postData: {},
    submit: !1,
    subtext: "确认兑换",
    smsimgcode: "",
    verifycode_img: ""
  },
  onLoad: function (i) {
    e.getSet();
    e.checkAuth();
    e.url(i), t.loading(), this.getInfo();
  },
  getInfo: function () {
    var e, i = this;
    t.get("member/showcredit", {}, function (t) {
      if (t.error) wx.redirectTo({
        url: "/pages/member/index/index"
      }); else {
        var a = {
          member: t.member,
          need_sns: t.need_sns,
          binded: t.binded,
          endtime: t.endtime,
          show: !0,
          smsimgcode: t.smsimgcode,
          verifycode_img: t.verifycode_img
        };
        a.postData = {
          mobile: t.member.mobile,
          code: "",
          password: "",
          password1: ""
        }, i.setData(a), t.endtime > 0 && i.endTime(), e = t.binded ? "修改密码" : "修改密码",
          wx.setNavigationBarTitle({
            title: t.member.moneytext+'兑换'+t.member.credittext
          });
      }
    }, !0, !0, !0);
  },

  inputChange: function (e) {
    var i = this.data.postData, s = t.pdata(e).type, o = e.detail.value;
    i[s] = a.trim(o), this.setData({
      postData: i
    });
  },

  submit: function (e) {
    if (!this.data.submit) {
      var s = this, o = this.data.postData;
       o.money && o.money>0 ? o.password && "" != o.password   ? (this.setData({
        submit: !0,
        subtext: "正在兑换.."
      }), t.post("member/showcredit/submit", o, function (e) {
        i.toast(s, e.message)
        if(0 != e.error){

            s.setData({
            submit: !1,
            subtext: "确认转换"
          })


        }else{
          wx.navigateBack()
        }


      }, !0, !0, !0))   : i.toast(this, "请填写支付密码"): i.toast(this, "请填写兑换金额");
    }
  }
});